#include "Object.h"

Object::Object(void)
    : posicao(0,0), tamanho(2,2),
      speed(0), angle(0), visible(true), material(NULL), name()
{
}

Object::Object(const Object& rhs)
	: posicao(rhs.posicao), tamanho(rhs.tamanho),
      speed(rhs.speed), angle(rhs.angle), visible(rhs.visible),
      material(rhs.material), name(rhs.name)
{

}
Object& Object::operator=(const Object& rhs)
{
	if( this != &rhs )
	{
		posicao = rhs.posicao;
		tamanho = rhs.tamanho;
		speed = rhs.speed;
		angle = rhs.angle;
		visible = rhs.visible;
		material = rhs.material;
		name = rhs.name;
	}
	return *this;
}

Object::~Object(void)
{
    //dtor
}
Material* Object::getMaterial(void)
{
	return material;
}
void Object::setMaterial( Material* m )
{
    material = m;
}

void Object::draw(void)
{
	if( !visible ) return;

    if( material )
    {
        material->usarMaterial();
    }

    glTranslatef( posicao.x, posicao.y, 0 );
    glRotatef( angle, 0, 0, 1 );
    angle += speed;

    // desenha o quad
    glBegin(GL_QUADS);
        glTexCoord2f(0.0f,0.0f);
        glVertex2f(  - 0.5*tamanho.x,  - 0.5*tamanho.y);

        glTexCoord2f(1.0f,0.0f);
        glVertex2f(  + 0.5*tamanho.x,  - 0.5*tamanho.y);

        glTexCoord2f(1.0f,1.0f);
        glVertex2f(  + 0.5*tamanho.x,  + 0.5*tamanho.y);

        glTexCoord2f(0.0f,1.0f);
        glVertex2f(  - 0.5*tamanho.x,  + 0.5*tamanho.y);
    glEnd();
}
